<?php

	class Cards extends CI_Controller
	{
		function __construct()
		{
			parent::__construct();
			$this->load->model('card_model');
		}

		function getdeck()
		{
			$suits = $this->card_model->get_suits();
			$faces = $this->card_model->get_faces();

			$deck = array ();

			foreach ($suits as $suit){
				foreach ($faces as $face){
					$deck[] = array("face"=>$face, "suit"=>$suit);
				}
			}

			shuffle($deck);

			return $deck;
		} //end getdeck

		function draw($deck, $hand)
		{
			//$player1 and $player2 = arrays
			if(count($hand) == 0) //initial draw of six cards
			{
				for ($i = 0; $i < 6; $i++)
				{
					$hand[] = implode(" of ", array_shift($deck));
				}
				return $hand;
			}
			else
			{
				for ($i = count($hand); $i < 6; $i++)
				{
					$hand[] = implode(" of ", array_shift($deck));
				}
				return $hand;
			}
		} //end draw
	}

?>